
import xadmin

from .models import Criteria,ReviewClause, ReviewKey, ReviewReference,RefFile

class CriteriaAdmin(object):
    list_display = ['id','name', 'code', 'pub_date','effective_date']
    list_filter = ['id','name', 'code', 'pub_date','effective_date']

xadmin.site.register(Criteria, CriteriaAdmin)

class ReviewClauseAdmin(object):
    list_display = ['id','criteria','name','desc', 'level','parent', 'sort']
    list_filter = ['id','criteria','name','desc', 'level','parent', 'sort']

xadmin.site.register(ReviewClause, ReviewClauseAdmin)

class ReviewKeyAdmin(object):
    list_display = ['id','clause','code','name',  'level','sort','desc','document','interview','inspect']
    list_filter = ['id','clause','code','name',  'level','sort','desc']
    ordering=['id']

    def get_queryset(self, request):
        qs = super().get_queryset(request)
        return qs.filter(clause__criteria__id=3)

xadmin.site.register(ReviewKey, ReviewKeyAdmin)

class ReviewReferenceAdmin(object):
    list_display = ['id', 'clause', 'type','sort']
    list_filter = ['id', 'clause', 'type','sort']


xadmin.site.register(ReviewReference, ReviewReferenceAdmin)


class RefFileAdmin(object):
    list_display = ['id','name', 'clause', 'sort']
    list_filter = ['id','name', 'clause', 'sort']


xadmin.site.register(RefFile, RefFileAdmin)
